package gscrapper.dao;

import gscrapper.entity.SonyGameInfo;

import java.util.List;

public class SonyGameInfoFileDAO implements SonyGameInfoDAO {
	public void save(List<SonyGameInfo> list) {
		StringBuilder builder = new StringBuilder(
				"Title,Description,Publisher,Purchased,Expiration Date\n");

		for (SonyGameInfo game : list) {
			builder.append(String.format("%s,%s,%s,%s,%s\n", //
					CSVHelper.toCSV(game.getTitle()), //
					CSVHelper.toCSV(game.getDescription()), //
					CSVHelper.toCSV(game.getPublisher()), //
					CSVHelper.toCSV(game.getPurchasedAsString()), //
					CSVHelper.toCSV(game.getExpirationAsString())));
		}

		CSVHelper.saveToFile("sonygameinfo", builder.toString());
	}
}
